2. More counting techniques#
We will now add two operations to our counting toolkit.
The difference rule counts allowed objects by removing forbidden ones.
The division principle corrects a construction that overcounts the same outcome multiple times.
We then use these rules to derive formulas for permutations and combinations - important counting problems that differ by whether order is considered important or not.
Finally, we discuss how strings and sets can be used to model a variety of different combinatorial problems using bijections.
2.1 The difference rule#
We used Theorem 1.10 to count the elements in a set by subdividing them into separate cases. When solving problems that impose restrictions on the allowed outcomes, it is convenient to first count the total number of possible outcomes and subtract those that are not allowed.
Let
Because
In Example 1.20, we counted the length-a-z in which no letter appears three times by separating them into cases.
Let us now count the same set using subtraction.
Solution: An outcome is an ordered string of three letters. Let
This agrees with the earlier case-based count, but subtraction produces the shorter model.
Suppose
A four-digit PIN is a string of four digits from 0-9; leading zeroes are allowed.
How many four-digit PINs have no repeated digit and contain at least one odd digit?
Incorrect solution:
Let
We want to remove the PINs containing no odd digit. The number of strings
The issue is that 2248. This pin was not accounted for in
Correct solution:
Instead, let
The modeling lesson is that the universe and the forbidden set must enforce the same background restrictions.
Here, "no repeated digit" is part of the definition of both
2.1.1 Counting the same set in two ways#
In Example 1.20 and Example 2.2, we counted the same quantity in two different ways.
Our approaches clearly work for any alphabet with
The first approach applied to an alphabet of
By itself, this identity is not very exciting. One can show it by standard algebraic simplification. However, it is interesting because it shows how using different combinatorial approaches can provide a "combinatorial" explanation to important formulas from algebra. This idea is often referred to as double counting, and we will see more examples in the future.
2.1.2 More examples of subtraction#
How many length-0?
Solution: The objects are strings, so order matters, leading zeroes are allowed, and digits may repeat.
Let
We could try to count strings according to the position of a zero. However the cases would overlap because there are string that have several zeroes.
Instead we exclude the strings with no zero.
Each of the six positions has
The complement replaces overlapping cases with one product-rule count.
How many length-ab?
Solution: Let
Let ab. Their first two positions are fixed, and each of the remaining six positions has a or b in the other positions.
How many length-
Solution: There are aaaaa. So there are
2.2 The division principle and permutations#
Theorem 1.17 requires every outcome to be constructed uniquely by the specified sequence of choices. The division principle handles a controlled failure of that uniqueness.
Sometimes a convenient construction is not unique. If every outcome is represented the same number of times, we can correct the overcount.
Suppose a construction produces
Let us count all the possible representations
There are
outcomes (choices at step 1) There is
representations to choose from once the "outcome" has been established ( choices at step 2).
The number of choices at each step does not depend on the choices of the other steps so we apply the product rule to obtain:
Division is justified only when every outcome is represented exactly the same number of times. If some outcomes have more representations than others, there is no single overcounting factor by which to divide.
Next, we will apply this principle to count strings where the order of characters does not matter, but only the characters actually present do.
2.3 Unordered selections: combinations without repetition#
Lecture Note 1 introduced Section 1.3 as ordered objects and Section 1.1 as unordered collections. We now use the division rule to pass from ordered representations to unordered selections.
First, we introduce an important mathematical notation, the factorial.
For an integer
We also define
The factorial is closely related to the concept of order. Indeed let us count the ways
to order or arrange a total of
What is the number of anagrams (permutations) of a string of
Solution: A permutation of a string of
The product defining
We now have the notation needed to count unordered selections.
A
For integers
In other words, it is the number of ways to choose
For
Let as associate to each set the list of its elements: if
The number of strings of length
Return to part 1 of Problem 1.9: a company has
Solution: An outcome is a four-element subset of the set of employees. The employees are distinct, nobody can be selected twice, and positions on the committee are not distinguished. Therefore the number of committees is
If we had selected the four employees in sequence, we would have counted every committee
Do not divide by
We are now ready to solve the second part of the earlier challenge problem.
Return to part 2 of Problem 1.9: a company with
Solution 1: Let us split the selection into two steps. First we select the chair. Then, among the remaining 19 employees, we select a subset of 3 to serve as line members of the commitee.
Step 1 gives us 20 choices.
In step 2 we select a subset of 3 out of the remaining 19 employees. This can be done in
ways.
Each of these choices yields a valid committee and each possible commitee is the result of a unique choice in our described procedure. Therefore, by the product rule, the total number we are looking for is
abcd and acbd both correspond to a commitee with
By how much do we overcount? Any permutation of the last 3 characters gives the same outcome so every outcome is counted
2.4 Counting problems#
Many combinatorial problems can be solved by modeling them using settings we have become familiar with: ordered strings or unordered subcollections.
In particular, if we manage to esablish a "bijection" (a 1-to-1 and onto relationship) between a problem and another one we know how to solve, then the number of outcomes in both has to be the same.
Next we provide a list of examples linking common mathematical counting problems to the ones we already studied.
2.4.1 Number of subsets of a set#
Let
Solution: First, let us number the elements of
To a subset
There are
For
2.4.2 Functions from one set to another#
For sets
Suppose
Solution: List the elements of
Suppose
Solution: We require that different inputs must receive different outputs.
As before, list the elements of
Therefore we have estabished a bijection between injective functions
There are
Careful, it is easy to mess up the role of